<include file="Public:pagerForm" />
<script type="text/javascript">
<!--
var total_amount = $("input[name=total_amount]");
var trade_amount = $("input[name=trade_amount]");
$(function(){    
    // 初始化應收金額和實收金額
	total_amount.val((0).toFixed(3));
	trade_amount.val((0).toFixed(3));
	
});

function calculate(t, del){
    var tbody = $(t).parents('tbody');
    var total = 0;
    var fix = 0; //刪除的話應該忽略本行
    if (del == 1){
        //alert(0);
        $(t).parents("tr:first").each(function(){
            var orgTotal = 0;
            $(this).find('input').each(function(){
                if (this.name == 'items.orgTotal[]') orgTotal = this.value == '' ? 0 : 1*this.value;
            });
            fix = orgTotal;
        });
    }
    $(tbody).find('tr').each(function(){
        var orgTotal = 0;
        $(this).find('input').each(function(){
            if (this.name == 'items.orgTotal[]') orgTotal = this.value == '' ? 0 : 1*this.value;
        });
        total += orgTotal;
    });
    if (fix != 0){
        total -= fix;
    }
    total_amount.val(total.toFixed(3));
    trade_amount.val(total.toFixed(3));
}
//-->
</script>
<h2 class="contentTitle">收款单(SK)</h2>
<form class="pageForm required-validate"  action="__URL__/addOrders/navTabId/__MODULE__" method="post" onsubmit="return validateCallback(this, dialogAjaxDone)">
<div class="pageContent">
	<div class="pageFormContent" layoutH="97">
    <fieldset>
        <table>
        <tr>
          <td>单据编号：</td>
          <td><input class="required" name="ordernumber" size="30" type="text" value="{$newCode}" /></td>
          <td>单据日期：</td>
          <td><input class="date" name="ordertime" type="text" value="{$dtime}" /><a class="inputDateButton" href="javascript:;">选择</a></td>
         </tr>
         <tr>
          <td>客户单位：</td>
          <td>
          <input id="receivename" name="receivename.id" value="" type="hidden"/>
          <input class="required" name="receivename.orgName" type="text" postField="keyword" suggestFields="id"  size="50" readonly="true" />
	      <a class="btnLook" href="__APP__/Public/ckBackContacts/" lookupGroup="receivename" width="1000" height="450">查找带回</a>          
          </td>
          <td>经办人：</td>
          <td>
          <input id="orderUser" name="orderUser.id" value="" type="hidden"/>
          <input class="required" name="orderUser.orgName" type="text" postField="keyword" suggestFields="id"  readonly="true" />
	      <a class="btnLook" href="__APP__/Public/ckBackUser/" lookupGroup="orderUser">查找带回</a>          
          </td>
         </tr>
         <tr>
          <td>收款账户：</td>
          <td>          
            <input id="bankid" name="bankid.id" value="" type="hidden"/>
            <input class="required" name="bankid.bankname" type="text" postField="keyword" suggestFields="id" size="30"  readonly="true" />
	        <a class="btnLook" href="__APP__/Public/ckBackBankaccount/" lookupGroup="bankid">查找带回</a> 
          </td>
          <td>单据摘要：</td>
          <td colspan="3"><input name="remarks" size="60" type="text" /></td>
         </tr>
        </table>
    </fieldset>
    <fieldset>
<table class="list nowrap itemDetail" addButton="添加收款项目" width="100%">
<thead>
	<tr>
        <th type="text" name="items.id[]" fieldClass="readonly" readOnly="readonly" size="3">编 号</th>
		<th type="lookup" name="items.costname[]" lookupGroup="items" lookupUrl="__APP__/Public/ckBackCosttypes/" suggestFields="costname" size="20" fieldClass="required">费用类型</th>
		<th type="calculate" name="items.orgTotal[]" size="8"  fieldClass="required">收款金额(￥)</th>
        <th type="text" name="items.orgMark[]" size="70">备 注</th>
		<th onclick="calculate(this,1)" type="del" fieldClass="refreshAmount">删行</th>
	</tr>
</thead>
<tbody></tbody>
</table>
    </fieldset>
    </div>
	<div class="formBar">
    <label style="float:left">应收金额:<input name="total_amount" size="15" type="text" readonly="readonly" /></label>
    <label style="float:left">实收金额:<input name="trade_amount" size="15" type="text"  /></label>
    <input name="createManid" value="{$_SESSION[C('USER_AUTH_KEY')]}" type="hidden"/>
    <label style="float:left">制单人:<input name="createMan" value="{$Think.session.loginUserName}" size="8" type="text" readonly="true" /></label>    
	<label style="float: left;">&nbsp;&nbsp;&nbsp;是否結款:<input type="checkbox" id="goFunds" name="goFunds" value="1"  /></label>
    <ul>
		<li><div class="buttonActive"><div class="buttonContent"><button type="submit">提交单据</button></div></div></li>
		<li><div class="button"><div class="buttonContent"><button class="close" type="button">关闭退出</button></div></div></li>
	</ul>
	</div>
</div>
</form>

